/*
 * @LastEditTime: 2023-03-31 23:30:03
 * @Method: 
 * @Description: 
 */
package CodeTop;

public class Solution83 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) {
            return head;
        }
        ListNode pre = head, cur = head.next;
        while (cur != null) {
            if (pre.val != cur.val) {
                ListNode t = cur.next;
                pre.next = cur;
                pre = cur;
                cur = t;
            } else {
                cur = cur.next;
            }
        }
        pre.next = null;
        return head;
    }
}
